/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sims.dao;

import java.util.List;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import sims.entity.TbCategory;
import sims.library.ControllerCore;

/**
 *
 * @author NINH
 */
public class CategoryDao extends ControllerCore {

    @Override
    public void insert(Object obj) {
        super.insertCore(obj);
    }

    @Override
    public void update(Object obj) {
        super.updateCore(obj);
    }

    @Override
    public void delete(Object obj) {
        super.deleteCore(obj);
    }

    @Override
    public List getAll(Class type) {
        return super.getAllCore(type);
    }

    @Override
    public List getAll(String hql) {
        return super.getAllCore(hql);
    }

    @Override
    public Object getById(Class type, int id) {
        return super.getByIdCore(type, id);
    }

    @Override
    public int countPage(String hql, int maxresults) {
        return super.countPageCore(hql, maxresults);
    }

    @Override
    public int countPage(Class type, int maxresults) {
        return super.countPageCore(type, maxresults);
    }

    @Override
    public int executeUpdate(String hql) {
        return super.executeUpdateCore(hql);
    }

    @Override
    public List paging(String hql, int first, int max) {
        return super.pagingCore(hql, first, max);
    }

    @Override
    public List paging(Class type, int first, int max) {
        return super.pagingCore(type, first, max);
    }

    public DefaultComboBoxModel combobox() {
        Vector v = new Vector();
        List<TbCategory> cates = getAll(TbCategory.class);
        for (TbCategory c : cates) {
            v.add(c.getCateName());
        }
        return new DefaultComboBoxModel(v);
    }

    public Vector comboboxId() {
        Vector v = new Vector();
        List<TbCategory> cates = getAll(TbCategory.class);
        for (TbCategory c : cates) {
            v.add(c.getCateId());
        }
        return v;
    }
}
